package com.lx.zy.framework.config;

import com.linkingbus.util.LogUtil;
import com.linkingbus.util.idUtil.IdUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;


/**
 * @program: zy-vue
 * @description: 程序注解配置
 * @author: Lx
 * @create: 2019-10-17 08:11
 **/
@Configuration
//表示通过aop框架暴露该代理对象，aopContext能够访问
@EnableAspectJAutoProxy(exposeProxy = true)
// 指定要扫描的Mapper类的包的路径
@MapperScan("com.lx.zy.project.**.mapper")
public class ApplicationConfig
{
    public static final Logger logger = LogUtil.getLogger(ApplicationConfig.class);
    Environment environment;

    @Autowired
    public void setEnvironment(Environment environment)
    {
        logger.info("init....id util .....");
        this.environment = environment;
        Integer len = Integer.parseInt(environment.getProperty("linkingbus.id.machine.bit.len"));
        Integer id = Integer.parseInt(environment.getProperty("linkingbus.id.machine.id"));
        try
        {
            IdUtil.init(len, id);
        }
        catch (Exception e)
        {

        }

    }
}
